package com.example.system.controller.user;

import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.Result;
import com.example.common.core.domain.TableDataInfo;
import com.example.common.core.enums.ResultCode;
import com.example.system.domain.user.User;
import com.example.system.domain.user.dto.UserDTO;
import com.example.system.domain.user.dto.UserQueryDTO;
import com.example.system.service.user.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 23050
 * @version 1.0
 * @description: TODO
 * @date 2025/3/3 20:15
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {

    @Resource
    private UserService userService;



    /**
     * @author 23050
     * @description:  获取用户列表
     * @date: 2025/3/3 20:41
     * @param userQueryDTO
     * @return com.example.common.core.domain.TableDataInfo
     */
    @GetMapping("/list")
    public TableDataInfo list(UserQueryDTO userQueryDTO){
        return getTableDataInfo(userService.list(userQueryDTO));
    }



    /**
     * @author 23050
     * @description:  更新用户的状态信息 拉黑和解禁
     * @date: 2025/3/3 21:33
     * @param userDTO
     * @return com.example.common.core.domain.Result
     */
    @PutMapping("/updateStatus")
    public Result updateStatus(@RequestBody UserDTO userDTO){

        int ret = userService.updateStatus(userDTO);
        if (ret>0){
            return new Result(ResultCode.SUCCESS.getCode(),"操作成功","");
        }
        return new Result(ResultCode.FAILED.getCode(),"操作失败","");
    }











}
